package com.ruoyi.info.controller;

import com.ruoyi.common.constant.Constants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.model.LoginBody;
import com.ruoyi.framework.web.service.SysLoginService;
import com.ruoyi.health.service.IUserService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 前台用户登录 Controller
 * 
 * @author libin
 * @date 2023-08-16
 */
@Api("前台用户登录")
@RestController
@RequestMapping("/info")
public class FrontLoginController extends BaseController {


    @Autowired
    private SysLoginService loginService;

    /**
     * 登录
     */
    @PostMapping("/login")
    public AjaxResult login(@RequestBody LoginBody loginBody) {
        AjaxResult ajax = AjaxResult.success();
        // 生成令牌
        String token = loginService.loginFront(loginBody.getPhone(), loginBody.getPassword());
        ajax.put(Constants.TOKEN, token);
        return ajax;

    }




}
